<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form id="registerForm" action="">
    账号:<input type="text" name="account" value="admin"/><br/>
    密码:<input type="password" name="pwd" value="123456"/><br/>
    <input type="hidden" name="id" value="999"/><br/>
    用户名:<input type="text" name="userName" value="管理员"/><br/>
    性别: <input type="radio" name="gender" value="1" checked>男
          <input type="radio" name="gender" value="2">女<br/>
    运动: <input type="checkbox" name="sports" value="1" checked>篮球
            <input type="checkbox" name="sports" value="2" checked>乒乓球
            <input type="checkbox" name="sports" value="3">足球<br/>
    城市: <select name="city">
            <option value="-1">请选择</option>
            <option value="cd" selected>成都</option>
            <option value="my">绵阳</option>
            <option value="dy">德阳</option>
          </select><br/>
    文件: <input type="file" name="face"><br/>
    备注: <textarea name="remark" cols="30" rows="10">备注</textarea><br/>
    <input type="button" value="提交" id="submitBtn">

</form>
<script src="../res/plugins/jquery/jquery-2.2.0.js"></script>
<script src="../res/plugins/jquery-formToObject/jquery.formToObject.js"></script>
<script>
    $("#submitBtn").click(function(){
        var form = $("#registerForm");
        var data;
        // 序列化表单字符串
        data = form.serialize();
        console.log(data);
        // 序列化表单为数组
        data = form.serializeArray();
        console.log(data);
        // 序列化表单为JS对象
        data = form.formToObject();
        console.log(data);
        // 转换为JSON对象
        data = JSON.stringify(data);
        console.log(data);

        // 调用示例
        var data = $("#registerForm").formToObject();
        console.log(data);

    });

</script>
</body>
</html>